package com.aniu.cameramanager.util;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;

public class CameraUtil {
    /**
     * 根据当前是否在工作时间段，立即启用/禁用相机
     *
     * @param context
     * @param amStartWorkTime
     * @param amStopWorkTime
     * @param pmStartWorkTime
     * @param pmStopWorkTime
     */
    public static void blockOrUnblockCameraNow(Context context, int amStartWorkTime, int amStopWorkTime, int pmStartWorkTime, int pmStopWorkTime) {
        Intent intent = new Intent();
        intent.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
        intent.setComponent(new ComponentName("com.aniu.cameramanager","com.aniu.cameramanager.AlarmReceiver"));
        if (WorkTime.isNowWorkTime(amStartWorkTime, amStopWorkTime, pmStartWorkTime, pmStopWorkTime)) {
            context.sendBroadcast(intent.setAction("ACTION_BLOCK_CAMERA"));
        } else {
            context.sendBroadcast(intent.setAction("ACTION_UNBLOCK_CAMERA"));
        }
    }
}
